package com.retail.member.controller;

import com.retail.core.entity.result.Result;
import com.retail.member.client.ShopClient;
import com.retail.member.entity.request.MyShopRequest;
import com.retail.member.entity.vo.RetailMultiShopResVo;
import com.retail.member.entity.vo.RetailShopResVo;
import com.retail.shop.entity.vo.RetailShopVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "商户页面API", tags = "商户页面API")
@RestController
@RequestMapping("api/shop")
public class ShopApiController {

    private final ShopClient shopClient;

    public ShopApiController(ShopClient shopClient) {
        this.shopClient = shopClient;
    }

    @ApiOperation("得到用户订单-自己订单")
    @GetMapping("findOwnerShopByAdminId/{adminId}")
    public Result<List<RetailShopVo>> findOwnerShopByAdminId(@PathVariable("adminId") String adminId) {
        return shopClient.findOwnerShopByAdminId(adminId);
    }

    /**
     * 商户列表
     * @param adminId
     * @return
     */
    @ApiOperation("商户列表")
    @GetMapping("shopList/{adminId}")
    public Result<List<RetailMultiShopResVo>> shopList(@PathVariable("adminId") Long adminId) {
        return shopClient.shopList(adminId);
    }

    @ApiOperation("线下门店列表")
    @PostMapping("getOfflineAllShopList")
    public Result<List<RetailShopVo>> getOfflineAllShopList(@RequestBody MyShopRequest request) {
        return shopClient.getOfflineAllShopList(request.getSearch(), request.getCity());
    }

    @ApiOperation("我的商户列表")
    @PostMapping("myShopList")
    public Result<List<RetailShopVo>> myShopList(@RequestBody MyShopRequest request) {
        return shopClient.myShopList(request.getAdminId(), request.getSearch());
    }

    /**
     * 商户列表
     * @param shopId
     * @return
     */
    @ApiOperation("商户详情")
    @GetMapping("shopDetail/{shopId}")
    public Result<RetailShopResVo> shopDetail(@PathVariable("shopId") Long shopId) {
        return shopClient.shopDetail(shopId);
    }

    @GetMapping("toBeBindShop")
    public Result<List<RetailShopVo>> toBeBindShop() {
        return shopClient.toBeBindShop();
    }

    @GetMapping("bindShop/{adminId}/{shopId}")
    public Result<Integer> bindShop(@PathVariable("adminId")Long adminId,@PathVariable("shopId") Long shopId) {
        return shopClient.bindShop(adminId, shopId);
    }
}
